package com.thiny.android.app.tsms.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.thiny.android.app.tsms.R;
import com.thiny.android.app.tsms.model.Message;

public class MessageAdapter extends BasicAdapter<Message> {

	public MessageAdapter(Context context, List<Message> list) {
		super(context, list);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder;
		Message msg = getItem(position);
		if (msg == null) {
			return convertView;
		}
		if (convertView == null) {
			convertView = getInflater().inflate(R.layout.message_item, null);
			holder = new Holder();
			holder.icon = (ImageView) convertView.findViewById(R.id.msg_icon);
			holder.content = (TextView) convertView
					.findViewById(R.id.msg_content);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}

//		holder.icon.setImageDrawable(drawable);
		holder.content.setText(msg.getContent());
		return convertView;
	}

	private class Holder {
		public ImageView icon;
		public TextView content;
	}

}
